package cn.itcast.itcaststore.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/CheckCardServlet")
public class CheckCardServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        String login = (String) request.getSession().getAttribute("login");
        if ("true".equals(login)){
            response.sendRedirect(request.getContextPath()+"/AddCardServlet?id="+id);
        }else {
            response.sendRedirect(request.getContextPath()+"/client/login.jsp");
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
